package com.iut.sujet1.metier;

import com.iut.sujet1.exception.AppException;

public class Personne {
	
	private static int idmax;


	private int id;
	private String nom;
	private String prenom;
	private int age;
	
	public Personne(){
		super();
		this.id = 0;
		this.nom = "";
		this.prenom = "";
		this.age = 0;
	}
	
	public Personne(String nom, String prenom, int age) throws AppException {
		super();
		setId(0);
		setNom(nom);
		setPrenom(prenom);
		setAge(age);
	}
	public Personne(int id,String nom, String prenom, int age) throws AppException {
		super();
		setId(id);
		setNom(nom);
		setPrenom(prenom);
		setAge(age);
	}

	@Override
	public String toString() {
		return "Personne [id=" + id + ", nom=" + nom + ", prenom=" + prenom
				+ ", age=" + age + "]\n";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + age;
		result = prime * result + id;
		result = prime * result + ((nom == null) ? 0 : nom.hashCode());
		result = prime * result + ((prenom == null) ? 0 : prenom.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Personne other = (Personne) obj;
		if (age != other.age)
			return false;
		if (id != other.id)
			return false;
		if (nom == null) {
			if (other.nom != null)
				return false;
		} else if (!nom.equals(other.nom))
			return false;
		if (prenom == null) {
			if (other.prenom != null)
				return false;
		} else if (!prenom.equals(other.prenom))
			return false;
		return true;
	}

	public String getNom() {
		return nom;
	}
	public void setNom(String nom) {
		this.nom = nom;
	}
	public String getPrenom() {
		return prenom;
	}
	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) throws AppException {
		if(age <= 0 ){
			throw new AppException("Saisir un age > 0");
		}
		this.age = age;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	public static int getIdmax() {
		return idmax;
	}

	public static void setIdmax(int idmax) {
		Personne.idmax = idmax;
	}
	public boolean supeByNom(Personne pers){
		return getNom()/*.toUpperCase()*/.compareTo(pers.getNom()/*.toUpperCase()*/)>0?true:false;
	}
	public boolean infeByNom(Personne pers){
		return getNom()./*toUpperCase().*/compareTo(pers.getNom()/*.toUpperCase()*/)<0?true:false;
	}
	
	public boolean supeByNomUncase(Personne pers){
		return getNom()/*.toUpperCase()*/.compareTo(pers.getNom()/*.toUpperCase()*/)>0?true:false;
	}
	public boolean infeByNomUncase(Personne pers){
		return getNom()./*toUpperCase().*/compareTo(pers.getNom()/*.toUpperCase()*/)<0?true:false;
	}
	

	
}


